{extend name="public:base" /}
{block name="content"}
<link rel="stylesheet" href="__CSS__/bootstrapValidator.min.css">
<link rel="stylesheet" href="__CSS__/AdminLTE.min.css">
<style type="text/css">
    input.error { border: 1px solid red; }
    label.error {
        background:url("./demo/images/unchecked.gif") no-repeat 0px 0px;

        padding-left: 16px;

        padding-bottom: 2px;

        font-weight: bold;

        color: #EA5200;
    }
    .f_g_box{
        flex-flow: row wrap;
    }
    label.checked {
        background:url("./demo/images/checked.gif") no-repeat 0px 0px;
    }
</style>
<div class="back_btn">
    <!-- 返回按钮 -->
    <button class="btn btn_color" type="button" style="outline: none;">
        <a href="{:url('index/index')}"><span class="glyphicon glyphicon-arrow-left" style="color:#3c8dbc;font-size: 18px;"></span></a>
    </button>
    <button type="button" class="btn btn-info btn-xs pull-right " style="margin: 10px 10px;">
        <a href="{:url('index')}">返回首页</a>
    </button>
</div>
<div class="row_box">
    <div class="col_box">
        <div class="box-header" data-original-title="" style="height: 30px;">
            <span><i class="glyphicon glyphicon-plus"></i>修改订单</span>
        </div>
        <div class="input_box">
            <form action="{:url('edit')}" id="commentForm" method="post">
                <br>
                <br>
                <input type="hidden" name="id" value="{$info.id}" id="id" >
                <i><h4>顾客信息:</h4></i>
                <br>
                <div class="form-group f_g_box">
                    <label>姓名</label>
                    <input type="text" name="name" id="name" value="{$info.name}">
                </div>
                <div class="form-group f_g_box">
                    <label>电话(妈妈)</label>
                    <input type="text" class="form-control" name="maphone" value="{$info.maphone}"  id="maphone">
                </div>
                <div class="form-group f_g_box">
                    <label>电话(家人)</label>
                    <input type="text" class="form-control" name="otherphone" {neq name='info.otherphone' value='0'}value="{$info.otherphone}"{/neq} id="otherphone" >
                </div>
                <div class="form-group f_g_box">
                    <label>微信</label>
                    <input type="text" class="form-control" name="weixin" {neq name='info.weixin' value='0'}value="{$info.weixin}"{/neq} id="weixin" >
                </div>
                <div class="form-group f_g_box">
                    <label>QQ</label>
                    <input type="text" class="form-control" name="qq" {neq name='info.qq' value='0'}value="{$info.qq}"{/neq} id="qq" >
                </div>
                <div class="form-group f_g_box">
                    <label>预产期</label>
                    <input type="text" id="yctime"  onclick="laydate({min:laydate.now()})" name="yctime" {neq name="info.yctime" value="1970-01-01"}value="{$info.yctime}"{/neq}>
                </div>
                <div class="form-group f_g_box">
                    <label>照片分类</label>
                    <select class="form-control" name="fenlei">
                        <option value="">请选择</option>
                        {volist name='fenlei' id='data'}
                        <option value="{$data.id}" {eq name="info['fenlei']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>业务状态</label>
                    <select class="form-control" name="ywstate" id="ywstate">
                        {volist name='state' id='data'}
                        <option value="{$data.id}" {$data.status}{eq name="info['ywstate']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <br>
                <br>
                <i><h4>渠道信息：</h4></i>
                <br>
                <div class="form-group f_g_box">
                    <label>渠道</label>
                    <select class="form-control" name="qudao" id="qudao" >
                        <option value="">请选择渠道</option>
                        {volist name='qudao' id='data'}
                        <option value="{$data.id}" {eq name="info['qudao']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>区域</label>
                    <select class="form-control" name="area" id="area" onchange="loadRegion('area','parent_id','yiyuan','{:url('Ajax/region')}');">
                        <option value="">请选择</option>
                        {volist name='area' id='data'}
                        <option value="{$data.id}" {eq name="info['area']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>收集医院</label>
                    <select class="form-control" name="yiyuan" id="yiyuan">
                        <option value="">请选择</option>
                        {volist name='yiyuan' id='data'}
                        <option value="{$data.id}" {eq name="info['yiyuan']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>

                <div class="form-group f_g_box">
                    <label>医院渠道</label>
                    <select class="form-control" name="menzhen" id="menzhen">
                        <option value="">请选择</option>
                        {volist name='menzhen' id='data'}
                        <option value="{$data.id}" {eq name="info['menzhen']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>

                <div class="form-group f_g_box">
                    <label>渠道备注</label>
                    <textarea type="text" class="form-control" rows="5" name="qdbz" >{neq name='info.qdbz' value='0'}{$info.qdbz}{/neq}</textarea>
                </div>
                <br>
                <br>
                <i><h4>邀约信息：</h4></i>
                <br>
                <div class="form-group f_g_box">
                    <label>邀约客服</label>
                    <select class="form-control" name="yykf" disabled>
                        <option value="">请选择</option>
                        {volist name='yykf' id='data'}
                        <option value="{$data.id}" {eq name="info['yykf']" value="$data.id"}selected="selected"{/eq} >{$data.username}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>预约场馆</label>
                    <select class="form-control" name="yycg" disabled>
                        <option value="">请选择</option>
                        {volist name='yycg' id='data'}
                        <option value="{$data.id}" {eq name="info['yycg']" value="$data.id"}selected="selected"{/eq} >{$data.title}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>预约拍摄时间</label>
                    <input type="text" name="yypstime" class="form-control" disabled  onclick="laydate({min:laydate.now()})" {neq name="info.yypstime" value="1970-01-01 8:00"}value="{$info.yypstime}"{/neq} >
                </div>
                <div class="form-group f_g_box">
                    <label>追踪日期</label>
                    <input type="text" name="zztime" class="form-control" disabled    onclick="laydate({min:laydate.now()})" {neq name="info.zztime" value="1970-01-01"}value="{$info.zztime}"{/neq}>
                </div>
                <div class="form-group f_g_box">
                    <label>邀约备注</label>
                    <textarea type="text" class="form-control" rows="5" name="yybz" disabled >{neq name='info.yybz' value='0'}{$info.yybz}{/neq}</textarea>
                </div>
                <br>

                <i><h4>自动推送开关：</h4></i>
                <div class="form-group f_g_box">
                    <label>微信开关:</label>
                    <label style="width:20px;">开</label><input type="radio" name="wxkg"  value="1" {neq name="info.ywstate" value="7"} checked{/neq}  style="width:50px;height:25px;"  >
                    <label style="width:20px;">关</label><input type="radio" name="wxkg"  value="0"  {eq name="info.ywstate" value="7"}checked{/eq} style="width:25px;height:25px;"  >
                </div>
                <div class="btn_t">
                    <button id="submit">确定</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- 搜索 结束 -->
<!-- 列表 -->
{/block}

{block name="js"}
<script src="__JS__/jquery-2.2.3.min.js"></script>
<!--<script type="text/javascript" src="__STATIC__/layui/layui.js"></script>-->

<script type="text/javascript" src="__JS__/calendar.js"></script>
<script type="text/javascript" src="__JS__/region.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="__JS__/bootstrap.min.js"></script>
<script src="__JS__/bootstrapValidator.min.js"></script>
<!-- iCheck -->
<script src="__JS__/language/zh_CN.js"></script>

<script type="text/javascript" src="__STATIC__/laydate/laydate.js"></script>
<script type="text/javascript" src="__STATIC__/layer/layer.js"></script>
<script type="text/javascript" src="__JS__/yewu.js"></script>
<script type="text/javascript" src="__JS__/chachong.js"></script>

<script type="text/javascript">
    $(function () {
        /*判断是否是主管 和 专员*/
        var zgzy   = {$zgzy};
        var weixin = $('#weixin').val();
        var qq     = $('#qq').val();
        var otherphone = $('#otherphone').val();
        var ywstate = $('#ywstate').val();//意向客资
        if(zgzy == 1 || ywstate == 7 ){
            $("#maphone").attr('disabled','disabled');
        }
        if( (zgzy == 1 || ywstate == 7 ) && (otherphone != "" || otherphone != 0) ){
            $("#otherphone").attr('disabled','disabled');
        }
        if( (zgzy == 1 || ywstate == 7 ) && (weixin != "" || weixin != 0) ){
            $("#weixin").attr('disabled','disabled');
        }
        if( (zgzy == 1 || ywstate == 7)  && (qq != "" || qq != 0) ){
            $("#qq").attr('disabled','disabled');
        }

        $('#yctime').click(function () {
            var bootstrapValidator = $("#commentForm").data('bootstrapValidator');
            bootstrapValidator.updateStatus('yctime', 'NOT_VALIDATED').validateField('yctime');
        });

        $('#commentForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
            },
            fields: {
                name: {validators: {notEmpty: {message: '用户名不能为空'}}},
                yctime: {validators: {notEmpty: {message: '预产期不能为空'}, date : {format : "YYYY-MM-DD", message : "预产期格式不正确" }}},
                maphone: {validators: {notEmpty: {message: '妈妈电话不能为空'},
                        stringLength: {min: 11, max: 11, message: '请输入11位手机号码'},
                        regexp: {regexp: /^1[3|5|8]{1}[0-9]{9}$/, message: '请输入正确的手机号码'}}
                },
                otherphone: {validators: {stringLength: {min: 11, max: 11, message: '请输入11位手机号码'},
                    regexp: {regexp: /^1[3|5|8]{1}[0-9]{9}$/, message: '请输入正确的手机号码'}}
                },
                fenlei: {validators: {notEmpty: {message: '分类不能为空'}}},
                qudao: {validators: {notEmpty: {message: '渠道不能为空'}}},
                area: {validators: {notEmpty: {message: '区域不能为空'}}},
                yiyuan: {validators: {notEmpty: {message: '医院不能为空'}}},
                menzhen:{validators: {notEmpty: {message: '医院渠道不能为空'}}}
            }
        });
        $(document).keyup(function(event){
            if(event.keyCode ==13){
                $("#submit").trigger("click");
            }
        });
        $("#commentForm").submit(function(ev){ev.preventDefault();});
        $("#submit").on("click", function(){
            var bootstrapValidator = $("#commentForm").data('bootstrapValidator');
            bootstrapValidator.validate();
            if(bootstrapValidator.isValid()){

                $.ajax({
                    type: "POST",
                    url:  "{:url('edit')}",
                    data: $('#commentForm').serialize(),
                    beforeSend:function(){
                        $(this).attr("disabled","false"); //禁止点击
                    },
                    success: function(msg){
//                        console.log(msg);

                        if(msg.status==1){
                            $('#submit').attr("disabled","false"); //禁止点击
                            layer.msg(msg.info, {icon: 1});
                            setTimeout(function(){
                                location.href="{:url('index/listing')}";
                            },3000); //延迟演示
                        }else{
                            layer.msg(msg.info, {icon: 2});
                            $('#submit').removeAttr("disabled"); //禁止点击
                        }

                    }
                });
                return false;
            }else return;
        });
    });
    
</script>
{/block}

